package exception;

public class Person04 {
    private  int age;

    public Person04() {

    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IllegalAgeException {
        if(age<0||age>100){

//            throw  new RuntimeException("年龄不合法");
            throw  new IllegalAgeException("年龄不合法");//生成什么异常就要抛出什么异常

        }
        this.age = age;
    }
}
